package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.pojo.CheckGroup;
import com.itheima.service.CheckGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


//m分支
//b分支
//m分支
// 提交分支

// 修改权限
@RestController
@RequestMapping("/checkgroup")//asdas
public class CheckGroupController {
//adasd
    @Reference
    CheckGroupService  checkGroupService;

    //添加
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public Result add(@RequestBody CheckGroup checkGroup, Integer[] checkitemIds){
       return checkGroupService.add(checkGroup,checkitemIds);
       //测试01
        //123
    }

    //分页查询
    @RequestMapping(value = "/findPage",method = RequestMethod.POST)
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean){
        return checkGroupService.findByPage(queryPageBean);
        //123
    }

    //通过id查询检查组信息
    @RequestMapping(value = "/findById/{id}",method = RequestMethod.GET)
    public Result findById(@PathVariable Integer id){
        return checkGroupService.findById(id);
    }

    //通过id查询检查项信息
    @RequestMapping(value = "/findCheckItemIdsByCheckGroupId/{id}",method = RequestMethod.GET)
    public Result findCheckItemIdsByCheckGroupId(@PathVariable Integer id){
        return checkGroupService.findCheckGroupOrCheckItemById(id);
    }

    //修改检查组信息
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public Result update(Integer[] checkitemIds,@RequestBody CheckGroup checkGroup){
        return checkGroupService.update(checkGroup,checkitemIds);
    }

    //删除123123
    //修改检查组信息
    @RequestMapping(value = "/delete/{id}",method = RequestMethod.DELETE)
    public Result delete(@PathVariable Integer id){
        return checkGroupService.delete(id);
    }
    //查询所有检查组信息
    @RequestMapping(value = "/findAll", method = RequestMethod.GET)
    public Result findAll(){
        Result all = checkGroupService.findAll();
        return all;
    }
    //1
    //1
    // 熊翔
    // 熊翔
    // 2021512
}

